#include "propeties.h"
#include "ui_propeties.h"


Propeties::Propeties(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Propeties)
{
    ui->setupUi(this);
    this->m_config = NULL;
}

void Propeties::view()
{
    this->connect_all();
    this->show();
    emit OnShow();
}

void Propeties::connect_all()
{
    connect(this->ui->pb_TestConnection,SIGNAL(clicked()),this,SLOT(OnTestCOnnection()));
    connect(this->ui->pb_Save,SIGNAL(clicked()),this,SLOT(OnSave()));
    connect(this->ui->pb_Cancel,SIGNAL(clicked()),this,SLOT(OnCancel()));
}
void Propeties::disconnect_all()
{

}

Propeties::~Propeties()
{
    delete ui;
}
void Propeties::OnCancel()
{
    QMessageBox::information(0,"1","OnCancel");;
}
void Propeties::OnSave()
{
    QMessageBox::information(0,"1","OnSave");;
}
void Propeties::OnShow()
{
    this->m_sql.m_SetSqlDriver(this->ui->op_cb_db_type->currentText());;
}
void Propeties::OnTestCOnnection()
{
    this->m_sql.m_SetConnectionOptions
            (
                    this->ui->op_le_db_host->text(),
                    this->ui->op_cb_db_name->currentText(),
                    this->ui->op_le_db_user->text(),
                    this->ui->op_le_db_pwd->text(),
                    this->ui->op_sb_db_port->value()
            );
    this->m_sql.OnTestConnection();
}
